#include <display.h>
#include "oled.h"

Adafruit_GFX *dev;

int oled::begin(void *arg) const {
    dev = (Adafruit_GFX *) (arg);
    return 0;
}

extern "C"
{
void oled_drawString(int x, int y, const char *text, int size) {
    dev->setCursor(x, y);
    dev->setTextSize(size);
    dev->print(text);
}

void oled_drawFloat(int x, int y, float *val, int dec, int size) {
    dev->setCursor(x, y);
    dev->setTextSize(size);
    dev->print(*val, dec);
}

void oled_drawNumber(int x, int y, int val, int size) {
    dev->setCursor(x, y);
    dev->setTextSize(size);
    dev->print(val);
}

void oled_clear() {
    dev->fillScreen(0);

}
void oled_display() {
    dev->display();
}
const display_abi display = {
        .clear = &oled_clear,
        .string = &oled_drawString,
        .number_double = &oled_drawFloat,
        .number_int = &oled_drawNumber,
        .display=&oled_display};
}
